<?php
require('../../../global.php');
//进入页面后先判断是否有访问权限
checkAdminAuthorizeAndJump('publicClass.browse');
?>
<!DOCTYPE html>
<html>
<head>
    <?php require('admin/_head.php'); ?>
    <title>人员管理 - <?php echo getconfig('title'); ?>管理后台</title>
    <link href="<?php echo SITEROOTURL; ?>/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
     <link href="<?php echo SITEROOTURL; ?>/admin/js/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
</head>
<body class="gray-bg">
  
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h3>
                	<button type="button" class="btn btn-white btn-sm closelayer">返回</button>
                	公开课订单
                
                </h3>
            </div>
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-12">
                        <div id="toolbar" class="form-inline">

                            <div class="form-group">
                                <label class="control-label">订单状态：</label>
                                <select class="form-control" id="status">
                                    <option value="">全部</option>
                                    <option value="0">已关闭</option>
                                    <option value="1">未付款</option>
                                    <option value="2">已付预付款</option>
                                    <option value="3">已付全款</option>
                                    <option value="4">订单完成</option>
                                    
                                </select>
                            </div>
                        	
                        	                            <div class="form-group">
                                　<label class="control-label">筛选时间：</label>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-5">
                                    <input type="text" name="begin_time" id="begin_time" placeholder="请输入开始时间" class="form-control">
                                    <span class="help-block m-b-none"></span>
                                </div>
                            </div>
                            一
                            <div class="form-group">
                                <div class="col-sm-5">
                                    <input type="text" name="end_time" id="end_time" placeholder="请输入结束时间" class="form-control">
                                    <span class="help-block m-b-none"></span>

                                </div>
                            </div>  
                        	    
                        </div>
                        
                        
                        <table id="table" data-toggle="table" data-url="ajax.php?ac=listOrder&cid=<?php echo $_GET['id'];?>" data-classes="table table-hover table-condensed" data-striped="true" data-pagination="true" data-side-pagination="server" data-page-list="[10, 20]" data-search="true" data-show-refresh="true" data-toolbar="#toolbar" data-query-params="queryParams">
                            <thead>
                                <tr>
                                	<th data-field="order_number" data-halign="center" data-align="center">订单号</th>
                                    <th data-field="nickname"  data-halign="center" data-align="center">用户名</th>
                                    <th data-field="mobile"  data-halign="center" data-align="center" data-sortable="false">手机号号码</th>
                                    <th data-field="className" data-halign="center" data-align="center">课程名称</th>
                                    <th data-field="subsist" data-halign="center" data-align="center">预付款</th>
                                    <th data-field="full_payment" data-halign="center" data-align="center">全款金额</th>
                                    <th data-field="createtime" data-halign="center" data-align="center" data-sortable="true">创建时间</th>
                                    <th data-field="status" data-halign="center" data-align="center">状态</th>
                                    <th data-field="do" data-halign="center" data-align="center" data-width="150">操作</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php require('admin/_js.php'); ?>
    <!-- 自定义js -->
    <script src="<?php echo SITEROOTURL; ?>/admin/js/content.js?v=1.0.0"></script>
    <script>
    //此处为权限操作专属区域，禁止写其它业务逻辑代码
    $(function(){
        if($('#authorize-edit').val() == 0){
            $('.authorize-edit').hide();
        }
    });
    </script>
    <!-- Bootstrap table -->
    <script src="<?php echo SITEROOTURL; ?>/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/plugins/bootstrap-table/bootstrap-table-locale-all.min.js"></script>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script src="<?php echo SITEROOTURL; ?>/admin/js/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <script>
    $(function(){
    	var closeLayer = function(){
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.closeLayer(index);
        }
        $('.closelayer').click(function(event){
            closeLayer();
        });

        $('#begin_time').datetimepicker({
        	language : 'zh-CN',
            format : 'yyyy-mm-dd',
            weekStart : 1,
            startView : 2,
            minView : 2,
            todayHighlight : true,
            autoclose : true
        }).on('changeDate', function(){
        	$('#end_time').datetimepicker('setStartDate', $(this).val());
        });
        $('#end_time').datetimepicker({
        	language : 'zh-CN',
            format : 'yyyy-mm-dd',
            weekStart : 1,
            startView : 2,
           
            minView : 2,
            todayHighlight : true,
            autoclose : true
        }).on('changeDate', function(){
        	$('#begin_time').datetimepicker('setEndDate', $(this).val());
        });
        
        $('#table').on('click', '.remove', function(event){
            event.preventDefault();
            var id = $(this).data().id;
            swal({
                title: "您确定要删除该人员吗",
                text: "删除后将无法恢复，请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "是的，我要删除！",
                cancelButtonText: "我再考虑一下…",
                closeOnConfirm: false,
                showLoaderOnConfirm: true
            }, function(){
                $.ajax({
                    url: 'ajax.php',
                    type: 'POST',
                    dataType: 'json',
                    data: {
                        ac: 'delete',
                        id: id
                    }
                }).done(function(){
                    swal("删除成功！", "", "success");
                    $('#table').bootstrapTable('refresh', {silent: true});
                }).fail(function(){
                    swal("删除失败！", "请重新操作！", "error");
                });
            });
        }).on('click', '.schedule', function(event){
        	event.preventDefault();
            var id = $(this).data().id;
           
            layer.open({
                type: 2,
                title: false,
                closeBtn: false,
                area: ['100%', '100%'],
                shade: false,
                move: false,
                content: 'schedule.php?id='+id
            });
        })
        .on('click', '.payfull', function(event){
            event.preventDefault();
            var id = $(this).data().id;
            $.ajax({
                url: 'ajax.php',
                type: 'POST',
                dataType: 'json',
                data: {
                    ac: 'payFull',
                    id: id
                }
            }).done(function(){
                swal("全额付款完成！", "", "success");
                $('#table').bootstrapTable('refresh', {silent: true});
            }).fail(function(){
                swal("全额付款操作失败！", "请重新操作！", "error");
            });
        }).on('click', '.finish', function(event){
            event.preventDefault();
            var id = $(this).data().id;
            $.ajax({
                url: 'ajax.php',
                type: 'POST',
                dataType: 'json',
                data: {
                    ac: 'finish',
                    id: id
                }
            }).done(function(){
                swal("完成课程成功！", "", "success");
                $('#table').bootstrapTable('refresh', {silent: true});
            }).fail(function(){
                swal("完成课程失败！", "请重新操作！", "error");
            });
        });
        $('#add').click(function(event){
            event.preventDefault();
            layer.open({
                type: 2,
                title: false,
                closeBtn: false,
                area: ['100%', '100%'],
                shade: false,
                move: false,
                content: 'edit.php'
            });
        });

        $('#status, #begin_time, #end_time').on('change', function(){
            $('#table').bootstrapTable('refresh');
        });
    });
    function closeLayer(index){
        layer.close(index);
        $('#table').bootstrapTable('refresh', {silent: true});
    }
    function queryParams(params){
        params['status'] = $('#status').val();
        params['begin_time'] = $('#begin_time').val();
        params['end_time'] = $('#end_time').val();
        return params;
    }
    </script>
</body>
</html>
